package com.thinkfit.jy.adapter;

import android.content.Context;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.common.lib.bean.VideoBean;
import com.thinkfit.jy.R;

import org.jetbrains.annotations.NotNull;

public class TVAdapter extends BaseQuickAdapter<VideoBean, BaseViewHolder> {

    private Context mContext;
    private int mSelectIndex;

    public TVAdapter(Context context) {
        super(R.layout.item_tv);
        mContext = context;
        mSelectIndex = 0;
    }

    public void resetIndex(int index) {
        mSelectIndex = index;
        notifyDataSetChanged();
    }


    @Override
    protected void convert(@NotNull BaseViewHolder helper, VideoBean bean) {
        helper.setText(R.id.tvName, bean.getName())
                .setTextColor(R.id.tvName, ContextCompat.getColor(mContext,
                        mSelectIndex == getItemPosition(bean) ? com.common.lib.R.color.text_color_1 : com.common.lib.R.color.text_color_3));
    }

}
